package com.whj.controller;


import com.whj.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/message")
public class MessageController {
    @Autowired
    MessageService messageService;
    @RequestMapping("/showMessage")
    public String showMessage(Model model){
        model.addAttribute("messages",messageService.selectList());
        return "message";
    }
    @RequestMapping("/addMessage")
    public String addMessage(String ptuserName,String messageText){
        System.out.println(ptuserName+"  "+messageText);
        messageService.addMessage(ptuserName,messageText);
        return "redirect:/message/showMessage";
    }
}
